﻿@{
    ViewBag.Title = "WristPrint";
}
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Cache" content="no-cache" />
    <title>急性胸痛患者腕带打印</title>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/common.js?v=@DateTime.Now.ToString("yyyyMMdd")"></script>
    <script src="~/Scripts/CreateControl.js?v=@DateTime.Now.ToString("yyyyMMdd")" type="text/javascript"></script>
    <style type="text/css">
        html {  overflow-x: hidden; overflow-y: hidden; }
    </style>
</head>
<body style="height:400px;">
    <script type="text/javascript">
        CreatePrintViewerEx("100%", "80%", '@Url.Content("~/Grf/创伤.grf")' + '?id=' + getRnd(), "", true, "<param name=BorderStyle value=1>");
        $(document).ready(function () {            
            PrintStart();
        });
        function PrintStart() {            
            var pid = "@ViewBag.pid";          
            $.ajax({
                url: "/TraumaCenter/PatientList/Search?Id=" + pid, cache: false, success: function (data) {                    
                    var d = $.parseJSON(data);
                    if (d.Total > 0) {
                        //初始化模板
                        ReportViewer.Stop();
                        var Report = ReportViewer.Report;
                        var Recordset = ReportViewer.Report.DetailGrid.Recordset;

                        var row = d.Rows[0];
                        var PATIENT_ID = ReportViewer.Report.FieldByName("PATIENT_ID");
                        var PATIENT_NAME = ReportViewer.Report.FieldByName("PATIENT_NAME");
                        var PATIENT_SEX = ReportViewer.Report.FieldByName("PATIENT_SEX");
                        var PATIENT_AGE = ReportViewer.Report.FieldByName("PATIENT_AGE");

                        //加载模板
                        Report.PrepareLoadData();
                        Recordset.Append();

                        PATIENT_ID.AsString = row.PATIENT_ID == null ? "" : row.PATIENT_ID;
                        var PatCardNO = row.PatCardNO;
                        if (typeof (PatCardNO) != "undefined" && PatCardNO != null && PatCardNO != "" && PatCardNO.toString().length > 0) {
                            var spatcardno = PatCardNO.substring(0, 1);
                            var num_reg = /^\d+$/;
                            if (num_reg.test(spatcardno)) {
                                PATIENT_ID.AsString = PatCardNO;
                            }
                        }
                        PATIENT_NAME.AsString = row.PATIENT_NAME == null ? "" : row.PATIENT_NAME;
                        PATIENT_SEX.AsString = row.PATIENT_SEX == null ? "" : row.PATIENT_SEX == "1" ? "男" : row.PATIENT_SEX == "0" ? "女" : row.PATIENT_SEX;
                        PATIENT_AGE.AsString = row.PATIENT_AGE == null ? "" : row.PATIENT_AGE;

                        //输出数据
                        Recordset.Post();
                        ReportViewer.Start();
                    }
                }
            });
        }
    </script>
</body>
</html>